package org.lsms.servlet;

/**
 * servlet used to reset password
 * @author ZhanXueliang
 * 2010.8.31
 */

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lsms.dao.impl.DaoImpl;

public class forget_pass extends HttpServlet {

	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			String loginname = request.getParameter("loginname");
			String email = request.getParameter("email");
			
			DaoImpl impl = new DaoImpl();
			
			if(impl.reset_pass(loginname, email)){
				String info = "Your password has been reset to<font color='red'> 123456</font>.\n" +
						"Please use this new password to login!";
				response.sendRedirect("show_info.jsp?info="+info);
			}else{
				response.sendRedirect("error/pass_reset_fail.jsp");
			}
	}

	public void init() throws ServletException {

	}

}
